package cn.ltgodm.moj.strategy;


import cn.ltgodm.moj.model.enums.QuestionSubmitLanguageEnum;
import cn.ltgodm.moj.model.sandbox.JudgeInfo;
import cn.ltgodm.moj.strategy.impl.CPPJudgeStrategy;
import cn.ltgodm.moj.strategy.impl.DefaultJudgeStrategy;
import cn.ltgodm.moj.strategy.impl.JavaJudgeStrategy;
import org.springframework.stereotype.Service;

@Service
public class JudgeStrategyManager {

    public JudgeInfo doJudge(JudgeContext judgeContext) {
        String language = judgeContext.getQuestionSubmit().getLanguage();
        JudgeStrategy judgeStrategy;
        switch (QuestionSubmitLanguageEnum.getEnumByValue(language)) {
            case JAVA:
                judgeStrategy = new JavaJudgeStrategy();
                break;
            case CPLUSPLUS:
                judgeStrategy = new CPPJudgeStrategy();
                break;
            default:
                judgeStrategy = new DefaultJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
